package com.yzq.enums;

import lombok.Getter;

/**
 * 用户角色枚举
 **/
@Getter
public enum UserRole {
    ADMIN("admin","管理员"),
    USER("user","普通用户");
    private final String code;
    private final String message;

    UserRole(String code, String message) {
        this.code = code;
        this.message = message;
    }
    public static String getMessageByCode(String code) {
        for (UserRole value : UserRole.values()) {
            if (value.code.equals(code)) {
                return value.message;
            }
        }
        return null;
    }

    public static String getCodeByMessage(String message) {
        for (UserRole value : UserRole.values()) {
            if (value.message.equals(message)) {
                return value.code;
            }
        }
        return null;
    }
}
